import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Color;

// change 2 by viren

public class Pavan {
	int num1,num2,ans;

	JFrame frame;
	private JTextField text;
	private JTextField text2;
	private JTextField answer;
	private JTextField textField;
	private JLabel lblResultForMinus;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Pavan window = new Pavan();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public Pavan() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.getContentPane().setBackground(new Color(255, 204, 204));
		frame.setBounds(100, 100, 532, 376);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(null);
		
		JButton btnAddition = new JButton("Addition  ");
		btnAddition.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				
				
				try{
					num1=Integer.parseInt(text.getText());
					num2=Integer.parseInt(text2.getText());
					
					ans=num1+num2;
					answer.setText(Integer.toString(ans));
				}catch(Exception e1){ 
					JOptionPane.showMessageDialog(null, "enter the correct value");
					
				}
			}
		});
		btnAddition.setBounds(228, 283, 115, 23);
		frame.getContentPane().add(btnAddition);
		
		JButton answer1 = new JButton("Subtraction\r\n");
		answer1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				try{
					num1=Integer.parseInt(text.getText());
					num2=Integer.parseInt(text2.getText());
					ans=num1-num2;
					textField.setText(Integer.toString(ans));
				}catch(Exception e2){
					JOptionPane.showMessageDialog(null, "please a enter a correct number");
				}
			}
		});
		answer1.setBounds(370, 283, 115, 23);
		frame.getContentPane().add(answer1);
		
		text = new JTextField();
		text.setBounds(228, 51, 103, 23);
		frame.getContentPane().add(text);
		text.setColumns(10);
		
		text2 = new JTextField();
		text2.setBounds(436, 51, 103, 23);
		frame.getContentPane().add(text2);
		text2.setColumns(10);
		
		answer = new JTextField();
		answer.setBounds(357, 133, 99, 23);
		frame.getContentPane().add(answer);
		answer.setColumns(10);
		
		JLabel lblNewLabel = new JLabel("Result For Addition :\r\n");
		lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 15));
		lblNewLabel.setBounds(193, 133, 168, 19);
		frame.getContentPane().add(lblNewLabel);
		
		JLabel lblNumber = new JLabel("Enter the FirstNumber \r\n");
		lblNumber.setFont(new Font("Tahoma", Font.BOLD, 15));
		lblNumber.setBounds(54, 55, 203, 19);
		frame.getContentPane().add(lblNumber);
		
		JLabel lblNumber_1 = new JLabel("Number2");
		lblNumber_1.setFont(new Font("Tahoma", Font.BOLD, 15));
		lblNumber_1.setBounds(353, 51, 83, 19);
		frame.getContentPane().add(lblNumber_1);
		
		textField = new JTextField();
		textField.setBounds(357, 178, 99, 23);
		frame.getContentPane().add(textField);
		textField.setColumns(10);
		
		lblResultForMinus = new JLabel("Result For Minus");
		lblResultForMinus.setFont(new Font("Tahoma", Font.BOLD, 16));
		lblResultForMinus.setBounds(193, 180, 150, 14);
		frame.getContentPane().add(lblResultForMinus);
	}
}
